import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Result } from 'src/model/result';
import { User } from 'src/model/user.model';
import { ResultUtil } from 'src/utils/resultUtil';
import { Connection, Repository } from 'typeorm';

@Injectable()
export class UserService {

  constructor(@InjectRepository(User)
  private readonly userRepository: Repository<User>,
    private connection: Connection
  ) { }
  async save(user: User): Promise<Result<any>> {
    return ResultUtil.success(await this.userRepository.save(user));
  }

  async list(): Promise<Result<any>> {
    return ResultUtil.success(await this.userRepository.find())
  }
}
